//
//  NSDictionary+IMB.m
//  microtraining
//
//  Created by 闫建刚 on 14-7-21.
//  Copyright (c) 2014年 iMobile. All rights reserved.
//

#import "NSDictionary+IMB.h"

@implementation NSDictionary (IMB)

- (NSString*)toJsonString{
    if ([NSJSONSerialization isValidJSONObject:self]) {
        NSError *err;
        NSData *data = [NSJSONSerialization dataWithJSONObject:self options:0 error:&err];
        if (err) {
            NSLog(@"%@",[err localizedDescription]);
            return nil;
        }else{
            NSLog(@"%@",[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]);
            return [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
        }
    }
    NSLog(@"无效的JSON对象...");
    return nil;
} // 转换成JSON对象

@end
